<?php
/**
 * Created by PhpStorm.
 * User: yellow
 * Date: 2019/4/1
 * Time: 14:57
 */

namespace app\common\model;

use think\Model;

class User extends Model
{

    protected $insert = ['status' => 0];
    protected static $status = [0=>'未审核', 1=>'生效', 2=>'冻结'];

    protected static function init(){
        //TODO:初始化内容
        self::observe(\app\common\event\Users::class);
    }

    public function info(){
        return $this->hasOne('UserInfo', 'id', 'business_id');
    }

    public function siteName(){
        return $this->hasOne('site', 'id', 'site_id')->bind([
            'sName'=>'name'
        ]);
    }

    public function getStatusAttr($value){
        return self::$status[$value];
    }

    public function getCreateTimeAttr($value){
        return date('Y-m-d H:i', $value);
    }
    public function getSiteTimeAttr($value){
        return date('Y-m-d H:i', $value);
    }
}